class BitUtility(object):
    @staticmethod
    def align_greater_equal(v: int, base: int) -> int:
        if v > base:
            return v if (v & (v-1) == 0) else (1 << v.bit_length())
        else:
            return base

    @staticmethod
    def is_two_power(v: int) -> bool:
        return v > 0 and  (v & (v -1) == 0) 

class Bit(object):
    MASK = 0xFFFFFFFFFFFFFFFF
    def __init__(self, bindex):
        self.__bindex = 63 if bindex >= 64 else bindex

    def bindex(self) -> int:
        return self.__bindex

    def value(self) -> int: 
        return 1 << self.__bindex

    def mask(self) -> int:
        return (1 << (self.__bindex + 1) ) - 1

    def clear(self, v: int) -> int:
        return v & (~(1 << self.__bindex) & Bit.MASK)
         
    def set(self, v: int) -> int:
        return v | (1 << self.__bindex)

    def is_set(self, v: int) -> bool:
        return ((1 << self.__bindex) & v) != 0

    def is_clear(self, v: int) -> bool:
        return ((1 << self.__bindex) & v) == 0


